{% extends 'layout.html' %}

{% block content %}
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <!-- /.box-header -->
                <div class="box-body">
                    <div class="form-horizontal">
                        <div class="form-group">
                            <label class="control-label col-md-2">脚本名称<span class="red">&nbsp;*&nbsp;</span>:</label>
                            <div class="col-md-10">
                                <input id="arg" name="name" type="text" value="执行脚本-2017641711017" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-2">执行账户<span class="red">&nbsp;*&nbsp;</span>:</label>
                            <div class="col-md-10">
                                <input id="arg" name="arg" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-2">目标机器<span class="red">&nbsp;*&nbsp;</span>:</label>
                            <div class="col-md-10">
                                <button id="btn_chosen" type="button" class="btn btn-success"><i
                                        class="fa fa-desktop"></i>&nbsp;选择服务器
                                </button>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-10">
                                <input id="tgt" name="tgt" type="text" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-2">脚本来源<span class="red">&nbsp;*&nbsp;</span>:</label>
                            <div class="col-md-10">
                                <label class="radio-inline"> <input type="radio" id="mRadio" value="1" name="scriptfrom"
                                                                    checked="checked">
                                    手工录入
                                </label> <label class="radio-inline"> <input type="radio" value="2" name="scriptfrom">脚本克隆
                            </label> <label class="radio-inline"> <input type="radio" value="3" name="scriptfrom">本地脚本
                            </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-2">脚本内容<span class="red">&nbsp;*&nbsp;</span>:</label>
                            <div class="col-md-10">
                                <textarea id="ret" rows="15" name="ret" class="form-control"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-2">脚本参数:</label>
                            <div class="col-md-10">
                                <input id="arg" name="arg" type="text" placeholder="请输入脚本参数" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label col-md-2">超时时间:</label>
                            <div class="col-md-10">
                                <input id="arg" name="scripttimeout" type="text" value="1000" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-md-12">
                                <button id="btn_exec" class="btn btn-success pull-right">
                                    <i class="fa fa-life-saver"></i> 执行
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block self_footer_js %}
    <script>
        // add button
        $("#btn_chosen").click(function () {
            var addDialog = new BootstrapDialog({
                title: "新建定时任务",
                closable: false,
                draggable: true,
                message: function (dialog) {
                    var $message = $('<div></div>');
                    var pageToLoad = dialog.getData('pageToLoad');
                    $message.load(pageToLoad);
                    return $message;
                },
                data: {
                    'pageToLoad': "{% url 'chosen_server' %}"
                },
                buttons: [{
                    cssClass: "btn-default",
                    label: "保存",
                    action: function (dialogItself) {
                        $.post($("#group_form").attr("action"), $("#group_form").serializeArray(), function (data) {
                            if (data.code == 1) {
                                $table.bootstrapTable("refresh");
                                dialogItself.close();
                                addDialog.close();
                            }
                            else BootstrapDialog.alert(data.message);
                        }, "json");
                        //$("#groupForm").validate();
                    }
                }, {
                    cssClass: 'btn-white',
                    label: "取消",
                    action: function (dialogItself) {
                        dialogItself.close();
                    }
                }]
            });
            addDialog.open();
        });
    </script>
{% endblock %}